package com.tiancheng.trade.settlement.util;

import com.tiancheng.trade.settlement.enums.*;
import com.tiancheng.trade.settlement.vo.settlement.api.KeyValueVO;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class DictUtil {

    private static String settlementClearRuleEnum = "settlementClearRule";
    private static String settlementCycleModeEnum = "settlementCycleMode";
    private static String settlementRuleTypeEnum = "settlementRuleType";
    private static String settlementStatusEnum = "settlementStatus";
    private static String settlementTypeEnum = "settlementType";
    private static String dataTypeEnum = "dataType";
    private static String paymentChannelEnum = "payChannel";
    private static String billStatusEnum = "billStatus";
    private static String paymentBillStatusEnum = "paymentBillStatus";
    private static String payWayEnum = "payWay";
    private static String transactionTypeEnum = "transactionType";
    private static String invoiceTypeEnum = "invoiceType";
    private static String orderSourceEnum = "orderSource";


    private static Map<String, List<KeyValueVO>> map = new HashMap<>();


    public static Map<String, List<KeyValueVO>> getDict() {
        return map;
    }

    public static List<KeyValueVO> getDict(String dictType) {
        return map.get(dictType);
    }

    static {
        List<KeyValueVO> settlementClearRuleEnum = Arrays.stream(SettlementClearRuleEnum.values()).map(e -> {
            KeyValueVO KeyValueVO = new KeyValueVO();
            KeyValueVO.setKey(e.getCode());
            KeyValueVO.setValue(e.getDesc());
            return KeyValueVO;
        }).collect(Collectors.toList());
        map.put(DictUtil.settlementClearRuleEnum, settlementClearRuleEnum);

        List<KeyValueVO> settlementCycleModeEnum = Arrays.stream(SettlementRuleTypeEnum.values()).map(e -> {
            KeyValueVO KeyValueVO = new KeyValueVO();
            KeyValueVO.setKey(e.getCode());
            KeyValueVO.setValue(e.getDesc());
            return KeyValueVO;
        }).collect(Collectors.toList());
        map.put(DictUtil.settlementCycleModeEnum, settlementCycleModeEnum);

        List<KeyValueVO> settlementRuleTypeEnum = Arrays.stream(SettlementStatusEnum.values()).map(e -> {
            KeyValueVO KeyValueVO = new KeyValueVO();
            KeyValueVO.setKey(e.getCode());
            KeyValueVO.setValue(e.getDesc());
            return KeyValueVO;
        }).collect(Collectors.toList());
        map.put(DictUtil.settlementRuleTypeEnum, settlementRuleTypeEnum);

        List<KeyValueVO> settlementStatusEnum = Arrays.stream(SettlementStatusEnum.values()).map(e -> {
            KeyValueVO KeyValueVO = new KeyValueVO();
            KeyValueVO.setKey(e.getCode());
            KeyValueVO.setValue(e.getDesc());
            return KeyValueVO;
        }).collect(Collectors.toList());
        map.put(DictUtil.settlementStatusEnum, settlementStatusEnum);

        List<KeyValueVO> settlementTypeEnum = Arrays.stream(SettlementTypeEnum.values()).map(e -> {
            KeyValueVO KeyValueVO = new KeyValueVO();
            KeyValueVO.setKey(e.getCode());
            KeyValueVO.setValue(e.getDesc());
            return KeyValueVO;
        }).collect(Collectors.toList());
        map.put(DictUtil.settlementTypeEnum, settlementTypeEnum);

        List<KeyValueVO> dataTypeEnum = Arrays.stream(CostTypeEnum.values()).map(e -> {
            KeyValueVO KeyValueVO = new KeyValueVO();
            KeyValueVO.setKey(e.getCode());
            KeyValueVO.setValue(e.getDesc());
            return KeyValueVO;
        }).collect(Collectors.toList());
        map.put(DictUtil.dataTypeEnum, dataTypeEnum);

        List<KeyValueVO> paymentChannelEnum = Arrays.stream(PaymentChannelEnum.values()).map(e -> {
            KeyValueVO KeyValueVO = new KeyValueVO();
            KeyValueVO.setKey(e.getCode());
            KeyValueVO.setValue(e.getDesc());
            return KeyValueVO;
        }).collect(Collectors.toList());
        map.put(DictUtil.paymentChannelEnum, paymentChannelEnum);


        List<KeyValueVO> billStatusEnum = Arrays.stream(BillStatusEnum.values()).map(e -> {
            KeyValueVO KeyValueVO = new KeyValueVO();
            KeyValueVO.setKey(e.getCode());
            KeyValueVO.setValue(e.getDesc());
            return KeyValueVO;
        }).collect(Collectors.toList());
        map.put(DictUtil.billStatusEnum, billStatusEnum);


        List<KeyValueVO> paymentBillStatusEnum = Arrays.stream(PaymentBillStatusEnum.values()).map(e -> {
            KeyValueVO KeyValueVO = new KeyValueVO();
            KeyValueVO.setKey(String.valueOf(e.getCode()));
            KeyValueVO.setValue(e.getDesc());
            return KeyValueVO;
        }).collect(Collectors.toList());
        map.put(DictUtil.paymentBillStatusEnum, paymentBillStatusEnum);

        List<KeyValueVO> payWayEnum = Arrays.stream(PayWayEnum.values()).map(e -> {
            KeyValueVO KeyValueVO = new KeyValueVO();
            KeyValueVO.setKey(e.getCode());
            KeyValueVO.setValue(e.getDesc());
            return KeyValueVO;
        }).collect(Collectors.toList());
        map.put(DictUtil.payWayEnum, payWayEnum);

        List<KeyValueVO> transactionTypeEnum = Arrays.stream(TransactionTypeEnum.values()).map(e -> {
            KeyValueVO KeyValueVO = new KeyValueVO();
            KeyValueVO.setKey(e.getCode());
            KeyValueVO.setValue(e.getDesc());
            return KeyValueVO;
        }).collect(Collectors.toList());
        map.put(DictUtil.transactionTypeEnum, transactionTypeEnum);

        List<KeyValueVO> invoiceTypeEnum = Arrays.stream(InvoiceTypeEnum.values()).map(e -> {
            KeyValueVO KeyValueVO = new KeyValueVO();
            KeyValueVO.setKey(e.getCode());
            KeyValueVO.setValue(e.getDesc());
            return KeyValueVO;
        }).collect(Collectors.toList());
        map.put(DictUtil.invoiceTypeEnum, invoiceTypeEnum);

        List<KeyValueVO> orderSourceEnum = Arrays.stream(OrderSourceEnum.values()).map(e -> {
            KeyValueVO KeyValueVO = new KeyValueVO();
            KeyValueVO.setKey(e.getCode());
            KeyValueVO.setValue(e.getDesc());
            return KeyValueVO;
        }).collect(Collectors.toList());
        map.put(DictUtil.orderSourceEnum, orderSourceEnum);

    }
}
